package com.itheima.mall.dubbo.api.cms;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.mall.dubbo.mapper.cms.CmsSubjectMapper;
import com.itheima.mall.entity.domain.cms.Subject;
import com.itheima.mall.entity.page.MyPage;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class CmsSubjectServiceImpl extends ServiceImpl<CmsSubjectMapper, Subject> implements CmsSubjectService {
    @Autowired
    private CmsSubjectMapper subjectMapper;
    @Override
    public MyPage<Subject> getPage(String keyword, Integer pageNum, Integer pageSize) {
        Page<Subject> page = new Page<>(pageNum,pageSize);
        LambdaQueryWrapper<Subject> lqw = new LambdaQueryWrapper<>();
        lqw.like(keyword != null ,Subject::getCategoryName,keyword);
        subjectMapper.selectPage(page,lqw);
        MyPage<Subject> myPage = MyPage.init(page);
        return myPage;
    }
}
